org.neo4j.graphdb.traversal
Interface TraversalDescription


public interface TraversalDescription

Represents a description of a traversal. Here the rules and behaviour of a traversal is described. A traversal description is immutable and each method which adds or modifies the behaviour returns a new instances which includes the new modification, leaving the instance which returns the new instance intact. When all the rules and behaviours have been described the traversal is started using traverse(Node) where a starting node is supplied. The returned Traverser is then used to step through the graph, returning the positions matching the rules.


Method Summary
 TraversalDescription breadthFirst()
          A convenience method for order(BranchOrderingPolicy) where a "preorder breadth first" selector is used.
 TraversalDescription depthFirst()
          A convenience method for order(BranchOrderingPolicy) where a "preorder depth first" selector is used.
 TraversalDescription expand(RelationshipExpander expander)
          Sets the RelationshipExpander as the expander of relationships, discarding all previous calls to relationships(RelationshipType) and relationships(RelationshipType, Direction).
 TraversalDescription filter(Predicate<Path> filter)
          Sets the return filter to use, i.e.
 TraversalDescription order(BranchOrderingPolicy selector)
          Sets the BranchOrderingPolicy to use.
 TraversalDescription prune(PruneEvaluator pruning)
          Adds pruning to the list of PruneEvaluators which are used to prune the traversal.
 TraversalDescription relationships(RelationshipType type)
          Adds type to the list of relationship types to traverse.
 TraversalDescription relationships(RelationshipType type, Direction direction)
          Adds type to the list of relationship types to traverse in the given direction.
 Traverser traverse(Node startNode)
          Starts traversing from startNode based on all the rules and behaviour in this description.
 TraversalDescription uniqueness(Uniqueness uniqueness)
          Sets the Uniqueness to use.
 TraversalDescription uniqueness(Uniqueness uniqueness, Object parameter)
          Sets the Uniqueness to use.
 

Method Detail

uniqueness

TraversalDescription uniqueness(Uniqueness uniqueness)
Sets the Uniqueness to use.

Parameters:
uniqueness - the Uniqueness to use.
Returns:
a new traversal description with the new modifications.

uniqueness

TraversalDescription uniqueness(Uniqueness uniqueness,
                                Object parameter)
Sets the Uniqueness to use. It also accepts an extra parameter which is obligatory for certain uniqueness's, f.ex Uniqueness.NODE_RECENT.

Parameters:
uniqueness - the Uniqueness to use.
parameter - the extra parameter to go with the uniqueness.
Returns:
a new traversal description with the new modifications.

prune

TraversalDescription prune(PruneEvaluator pruning)
Adds pruning to the list of PruneEvaluators which are used to prune the traversal. The semantics for many prune evaluators is that if any one of the added prune evaluators returns true it's considered OK to prune there.

Parameters:
pruning - the PruneEvaluator to add to the list of prune evaluators to use.
Returns:
a new traversal description with the new modifications.

filter

TraversalDescription filter(Predicate<Path> filter)
Sets the return filter to use, i.e. which positions are OK to return. Each position is represented by a Path from the start node of the traversal to the current node. The current node is the Path.endNode() of the path.

Parameters:
filter - the Predicate to use as filter.
Returns:
a new traversal description with the new modifications.

order

TraversalDescription order(BranchOrderingPolicy selector)
Sets the BranchOrderingPolicy to use. A BranchSelector is the basic decisions in the traversal of "where to go next". Examples of default implementations are "breadth first" and "depth first", which can be set with convenience methods breadthFirst() and depthFirst().

Parameters:
selector - the factory which creates the BranchSelector to use with the traversal.
Returns:
a new traversal description with the new modifications.

depthFirst

TraversalDescription depthFirst()
A convenience method for order(BranchOrderingPolicy) where a "preorder depth first" selector is used. Positions which are deeper than the current position will be returned before positions on the same depth. See http://en.wikipedia.org/wiki/Depth-first_search

Returns:
a new traversal description with the new modifications.

breadthFirst

TraversalDescription breadthFirst()
A convenience method for order(BranchOrderingPolicy) where a "preorder breadth first" selector is used. All positions with the same depth will be returned before advancing to the next depth. See http://en.wikipedia.org/wiki/Breadth-first_search

Returns:
a new traversal description with the new modifications.

relationships

TraversalDescription relationships(RelationshipType type)
Adds type to the list of relationship types to traverse. There's no priority or order in which types to traverse.

Parameters:
type - the RelationshipType to add to the list of types to traverse.
Returns:
a new traversal description with the new modifications.

relationships

TraversalDescription relationships(RelationshipType type,
                                   Direction direction)
Adds type to the list of relationship types to traverse in the given direction. There's no priority or order in which types to traverse.

Parameters:
type - the RelationshipType to add to the list of types to traverse.
direction - the Direction to traverse this type of relationship in.
Returns:
a new traversal description with the new modifications.

expand

TraversalDescription expand(RelationshipExpander expander)
Sets the RelationshipExpander as the expander of relationships, discarding all previous calls to relationships(RelationshipType) and relationships(RelationshipType, Direction).

Parameters:
expander - the RelationshipExpander to use.
Returns:
a new traversal description with the new modifications.

traverse

Traverser traverse(Node startNode)
Starts traversing from startNode based on all the rules and behaviour in this description. A Traverser is returned which is used to step through the graph and getting results back.

Parameters:
startNode - the Node to start the traversal from.
Returns:
a Traverser used to step through the graph and to get results from.


Copyright © 2010 Neo4j. All Rights Reserved.